<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">订单用户</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="user_keys" placeholder="请输入手机或昵称" value="{$get.user_keys|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">来源用户</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="from_keys" placeholder="请输入手机或昵称" value="{$get.from_keys|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">订单单号</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="order_no" placeholder="请输入订单单号" value="{$get.order_no|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">是否需要发票</label>
        <div class="layui-input-inline">
            <select class="layui-select" name="getbill">
                <option value="">-- 全部 --</option>
                {foreach ['不需要', '需要'] as $k=>$v}
                {if $k.'' eq input('getbill')}
                <option selected value="{$k}">{$v}</option>
                {else}
                <option value="{$k}">{$v}</option>
                {/if}{/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">发货单号</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_send_number" placeholder="请输入发货单号" value="{$get.truck_send_number|default=''}">
        </label>
    </div>
    {if isset($type) and $type neq 7}
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">下单时间</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="create_at" placeholder="请选择下单时间" value="{$get.create_at|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">支付时间</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="payment_datetime" placeholder="请选择支付时间" value="{$get.payment_datetime|default=''}">
        </label>
    </div>
    {else/}
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">申请时间</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="reback_date" placeholder="请选择申请时间" value="{$get.reback_date|default=''}">
        </label>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">审核时间</label>
        <label class="layui-input-inline">
            <input class="layui-input" data-date-range name="reback_audit_date" placeholder="请选择审核时间" value="{$get.reback_audit_date|default=''}">
        </label>
    </div>
    {/if}
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收货姓名</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_address_name" placeholder="请输入收货姓名" value="{$get.truck_address_name|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收货手机</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_address_phone" placeholder="请输入收货手机" value="{$get.truck_address_phone|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">收货地址</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="truck_address_content" placeholder="请输入收货省份" value="{$get.truck_address_content|default=''}">
        </label>
    </div>
    <input type="hidden" name="type" value="{$type|default=0}">
    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary" type="submit"><i class="layui-icon">&#xe615;</i> 搜 索</button>
<!--        <button class="layui-btn layui-btn-primary" data-form-export="{:url('index')}?type={$type|default=''}" type="button">-->
<!--            <i class="layui-icon layui-icon-export"></i> 导 出-->
<!--        </button>-->
    </div>
</form>

<script>
    require(['excel'], function (excel) {
        excel.bind(function (data) {
            var items = [];
            items.push(['订单号', '用户手机', '用户姓名', '订单类型', '支付单号', '支付方式', '支付状态', '支付金额', '支付时间']);
            data.forEach(function (order) {
                items.push([
                    order.order_no,
                    order.user.phone,
                    order.user.username || order.user.nickname || '',
                    order.truck_type ? '虚拟商品' : '实物商品',
                    order.payment_trade || '',
                    order.payment_name || order.payment_type || '',
                    order.payment_status ? '已支付' : '未支付',
                    order.payment_amount || '0.00',
                    order.payment_datetime || '',
                ]);
            });
            return items;
        }, '用户订单记录');
    });
</script>
